#include "client.h"
#include "../utils/Configuration.h"

Connection::Connection() {

    Configuration& config = Configuration::getInstance();
    host = config.getMysqlHost();
    user = config.getMysqlUser();
    passwd = config.getMysqlPassword();
    db = config.getMysqlDataBases();

    driver = sql::mysql::get_mysql_driver_instance();
    connect = driver->connect(host, user, passwd);
    connect->setSchema(db);
}

Connection::~Connection() {
    if(connect != nullptr){
        delete connect;;
    }
}

void Connection::refresh() {
    timeoutTime = clock();
}

clock_t Connection::timeout() const {
    return clock() - timeoutTime;
}